<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="sitemesh" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html lang="en">
<head>
<title>${sysTitle}</title>
<style type="text/css">
.rap-app-logo {
	top: 5px;
	position: absolute;
	width: 35px;
	border-radius:50% !important;
}
.rap-app-title {
	color: #666666;
	font-size: 20px;
	font-weight: bold;
	margin-top: 10px;
	margin-left: 40px;
}
.rap-li-func span {
	position: absolute;
	right: 10px;
}

li.active > a {
	background: #3fd5c0;
}

.page-sidebar .page-sidebar-menu > li.sidebar-toggler-wrapper, 
.page-sidebar-closed.page-sidebar-fixed .page-sidebar:hover .page-sidebar-menu > li.sidebar-toggler-wrapper{
	margin-bottom : 10px;
}
.page-logo{
	width:500px;
}
</style>
</head>
<!-- BEGIN BODY -->
<!-- DOC: Apply "page-header-fixed-mobile" and "page-footer-fixed-mobile" class to body element to force fixed header or footer in mobile devices -->
<!-- DOC: Apply "page-sidebar-closed" class to the body and "page-sidebar-menu-closed" class to the sidebar menu element to hide the sidebar by default -->
<!-- DOC: Apply "page-sidebar-hide" class to the body to make the sidebar completely hidden on toggle -->
<!-- DOC: Apply "page-sidebar-closed-hide-logo" class to the body element to make the logo hidden on sidebar toggle -->
<!-- DOC: Apply "page-sidebar-hide" class to body element to completely hide the sidebar on sidebar toggle -->
<!-- DOC: Apply "page-sidebar-fixed" class to have fixed sidebar -->
<!-- DOC: Apply "page-footer-fixed" class to the body element to have fixed footer -->
<!-- DOC: Apply "page-sidebar-reversed" class to put the sidebar on the right side -->
<!-- DOC: Apply "page-full-width" class to the body element to have full width page without the sidebar menu -->

<body class="page-header-fixed page-sidebar-fixed">
	<!-- BEGIN HEADER -->
	<div class="page-header navbar navbar-fixed-top">
		<!-- BEGIN HEADER INNER -->
		<div class="page-header-inner">
			<!-- BEGIN LOGO -->
			<div class="page-logo">
				<img class="rap-app-logo" src="${ctx}/assets/stwy/img/logo.png">
				<label class="rap-app-title">${sysTitle}</label>
				<div class="menu-toggler sidebar-toggler hide">
					<!-- DOC: Remove the above "hide" to enable the sidebar toggler button on header -->
				</div>
			</div>
			<!-- END LOGO -->
			<!-- BEGIN RESPONSIVE MENU TOGGLER -->
			<a href="javascript:;" class="menu-toggler responsive-toggler"
				data-toggle="collapse" data-target=".navbar-collapse"> </a>
			<!-- END RESPONSIVE MENU TOGGLER -->
			<!-- BEGIN TOP NAVIGATION MENU -->
			<div class="top-menu">
				<ul class="nav navbar-nav pull-right">
					<!-- BEGIN WIN DROPDOWN -->
					<li class="dropdown dropdown-extended dropdown-windows"
						id="header_windows_bar"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown" data-hover="dropdown"
						data-close-others="true"> <i class="icon-eye"></i>
							<span class="badge badge-default rap-funcs-count">0</span>
					</a>
						<ul id="rap-ul-funcs-list" class="dropdown-menu windows">
							<li>
								<p>已打开<span class="rap-funcs-count">0</span>个窗口</p>
							</li>
							<li class="external"><a href="javascript:closeAllFunc();"> 关闭所有已打开窗口<i class="icon-cup"></i></a></li>
							<li class="external"><a href="javascript:showDashboard();">系统首页<i class="icon-home"></i></a></li>
						</ul>
					</li>
					<!-- END WIN DROPDOWN -->
					<!-- BEGIN NOTIFICATION DROPDOWN -->
					<li class="dropdown dropdown-extended dropdown-notification hide" id="header_notification_bar">
					<a href="#"
						class="dropdown-toggle" data-toggle="dropdown"
						data-hover="dropdown" data-close-others="true"> <i class="icon-bell"></i>
						<span class="badge badge-default"> 7 </span>
					</a>
						<ul class="dropdown-menu">
							<li>
								<p>你有7条新提示</p>
							</li>
							<li>
								<ul class="dropdown-menu-list scroller" style="height: 250px;">
									<li><a href="#"> <span
											class="label label-sm label-icon label-success"> <i
												class="fa fa-plus"></i>
										</span> New user registered. <span class="time"> Just now </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-danger"> <i
												class="fa fa-bolt"></i>
										</span> Server #12 overloaded. <span class="time"> 15 mins </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-warning"> <i
												class="fa fa-bell-o"></i>
										</span> Server #2 not responding. <span class="time"> 22 mins
										</span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-info"> <i
												class="fa fa-bullhorn"></i>
										</span> Application error. <span class="time"> 40 mins </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-danger"> <i
												class="fa fa-bolt"></i>
										</span> Database overloaded 68%. <span class="time"> 2 hrs </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-danger"> <i
												class="fa fa-bolt"></i>
										</span> 2 user IP blocked. <span class="time"> 5 hrs </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-warning"> <i
												class="fa fa-bell-o"></i>
										</span> Storage Server #4 not responding. <span class="time">
												45 mins </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-info"> <i
												class="fa fa-bullhorn"></i>
										</span> System Error. <span class="time"> 55 mins </span>
									</a></li>
									<li><a href="#"> <span
											class="label label-sm label-icon label-danger"> <i
												class="fa fa-bolt"></i>
										</span> Database overloaded 68%. <span class="time"> 2 hrs </span>
									</a></li>
								</ul>
							</li>
							<li class="external"><a href="#"> 查看所有提示 <i class="m-icon-swapright"></i>
							</a></li>
						</ul></li>
					<!-- END NOTIFICATION DROPDOWN -->
					<!-- BEGIN INBOX DROPDOWN -->
					<li class="dropdown dropdown-extended dropdown-inbox hide"
						id="header_inbox_bar"><a href="#" class="dropdown-toggle"
						data-toggle="dropdown" data-hover="dropdown"
						data-close-others="true"> <i class="icon-envelope-open"></i> <span
							class="badge badge-default"> 4 </span>
					</a>
						<ul class="dropdown-menu">
							<li>
								<p>你有12条新消息</p>
							</li>
							<li>
								<ul class="dropdown-menu-list scroller" style="height: 250px;">
									<li><a href="inbox.html?a=view"> <span class="photo">
												<img
												src="${ctx}/assets/metronic_v3.2.0/admin/layout/img/avatar2.jpg"
												alt="" />
										</span> <span class="subject"> <span class="from"> Lisa
													Wong </span> <span class="time"> Just Now </span>
										</span> <span class="message"> Vivamus sed auctor nibh congue
												nibh. auctor nibh auctor nibh... </span>
									</a></li>
									<li><a href="inbox.html?a=view"> <span class="photo">
												<img
												src="${ctx}/assets/metronic_v3.2.0/admin/layout/img/avatar3.jpg"
												alt="" />
										</span> <span class="subject"> <span class="from">
													Richard Doe </span> <span class="time"> 16 mins </span>
										</span> <span class="message"> Vivamus sed congue nibh auctor
												nibh congue nibh. auctor nibh auctor nibh... </span>
									</a></li>
									<li><a href="inbox.html?a=view"> <span class="photo">
												<img
												src="${ctx}/assets/metronic_v3.2.0/admin/layout/img/avatar1.jpg"
												alt="" />
										</span> <span class="subject"> <span class="from"> Bob
													Nilson </span> <span class="time"> 2 hrs </span>
										</span> <span class="message"> Vivamus sed nibh auctor nibh
												congue nibh. auctor nibh auctor nibh... </span>
									</a></li>
									<li><a href="inbox.html?a=view"> <span class="photo">
												<img
												src="${ctx}/assets/metronic_v3.2.0/admin/layout/img/avatar2.jpg"
												alt="" />
										</span> <span class="subject"> <span class="from"> Lisa
													Wong </span> <span class="time"> 40 mins </span>
										</span> <span class="message"> Vivamus sed auctor 40% nibh
												congue nibh... </span>
									</a></li>
									<li><a href="inbox.html?a=view"> <span class="photo">
												<img
												src="${ctx}/assets/metronic_v3.2.0/admin/layout/img/avatar3.jpg"
												alt="" />
										</span> <span class="subject"> <span class="from">
													Richard Doe </span> <span class="time"> 46 mins </span>
										</span> <span class="message"> Vivamus sed congue nibh auctor
												nibh congue nibh. auctor nibh auctor nibh... </span>
									</a></li>
								</ul>
							</li>
							<li class="external"><a href="inbox.html"> 查看所有消息 <i
									class="m-icon-swapright"></i>
							</a></li>
						</ul></li>
					<!-- END INBOX DROPDOWN -->
					<!-- BEGIN USER LOGIN DROPDOWN -->
					<li class="dropdown dropdown-user"><a href="#"
						class="dropdown-toggle" data-toggle="dropdown"
						data-hover="dropdown" data-close-others="true"> <img alt=""
							class="img-circle hide1"
							src="${ctx}/assets/rap/img/user.png" />
							<span class="username username-hide-on-mobile">
								<c:if test="${not empty user.orgName}">${user.orgName}-</c:if>${user.userName}
							</span>
							 <i class="fa fa-angle-down"></i>
					</a>
						<ul class="dropdown-menu">
							<!-- <li><a href="javascript:;" class="rap-config-toggler"> <i
									class="icon-settings"></i> 版面设置
							</a></li> -->
							<li><a href="javascript:;" id="rap-change-pwd"> <i
									class="icon-lock"></i> 修改密码
							</a></li>
							<!-- <li><a href="javascript:;" id="rap-profile"> <i
									class="icon-user"></i> 个人资料
							</a></li> -->
							<li class="divider"></li>
							<!-- 
						<li>
							<a href="extra_lock.html">
							<i class="icon-lock"></i> 锁定 </a>
						</li>
						 -->
							<li><a href="${ctx}/logout"> <i class="icon-key"></i>
									退出系统
							</a></li>
						</ul></li>
					<!-- END USER LOGIN DROPDOWN -->
					<!-- BEGIN QUICK SIDEBAR TOGGLER -->
					<li class="dropdown dropdown-quick-sidebar-toggler"><a
						href="#" onclick="onBack();" class="dropdown-toggle"> <i
							class="icon-logout"></i>
					</a></li>
					<!-- END QUICK SIDEBAR TOGGLER -->
				</ul>
			</div>
			<!-- END TOP NAVIGATION MENU -->
		</div>
		<!-- END HEADER INNER -->
	</div>
	<!-- END HEADER -->
	<div class="clearfix"></div>
	<!-- BEGIN CONTAINER -->
	<div class="page-container">
		<!-- BEGIN SIDEBAR -->
		<div class="page-sidebar-wrapper">
			<!-- DOC: Set data-auto-scroll="false" to disable the sidebar from auto scrolling/focusing -->
			<!-- DOC: Change data-auto-speed="200" to adjust the sub menu slide up/down speed -->
			<div class="page-sidebar navbar-collapse collapse">
				<!-- BEGIN SIDEBAR MENU -->
				<ul class="page-sidebar-menu " data-auto-scroll="true" data-slide-speed="200">
					<!-- DOC: To remove the sidebar toggler from the sidebar you just need to completely remove the below "sidebar-toggler-wrapper" LI element -->
					<li class="sidebar-toggler-wrapper">
						<!-- BEGIN SIDEBAR TOGGLER BUTTON
						<div class="sidebar-toggler"></div> 
						END SIDEBAR TOGGLER BUTTON -->
					</li> 

					<li class="rap-func start active">
						<a href="javascript:;" onclick="showDashboard();">
							<i class="icon-home"></i> <span class="title">首页</span>
						</a>
					</li>
					
					<!-- BEGIN FUNCTIONS MENU -->
					<c:forEach items="${functreeList}" var="cur">
						<c:if test="${cur.funcType=='module'}">
							<li class="rap-module"><a href="javascript:;"> 
							<c:if test="${ empty cur.iconcls }">
										<i class="fa fa-angle-right"></i>
									</c:if> <c:if test="${ not empty cur.iconcls }">
										<i class="${cur.iconcls}"></i>
									</c:if> <span class="title">${cur.funcName}</span> <span class="arrow"></span>
							</a>
						</c:if>
						<c:if test="${cur.funcType=='func'}">
							<c:set var="url" value="${fn:replace(cur.funcUrl,'@ctx@',ctx)}" />
							<li class="rap-func">
								<a href="javascript:;" onclick="openFunc('${cur.uuid}','${cur.funcName}','${url}');">
									<c:if test="${ empty cur.iconcls }">
										<i class="fa fa-angle-right"></i>
									</c:if> <c:if test="${ not empty cur.iconcls }">
										<i class="${cur.iconcls}"></i>
									</c:if> <span class="title">${cur.funcName}</span>
								</a>
							</li>
						</c:if>
						<c:if test="${not empty cur.children }">
							<!-- 如果有childen -->
							<c:set var="functreeList" value="${cur.children}" scope="request" />
							<!-- 注意此处，子列表覆盖treeList，在request作用域 -->
							<ul class="sub-menu">
								<c:import url="subfunc.jsp" />
								<!-- 这就是递归了 -->
							</ul>
						</c:if>
					</c:forEach>
					<!-- END FUNCTIONS MENU -->
	
					<li class="rap-func last ">
						<a href="javascript:;" onclick="showHelp();"> 
							<i class="icon-question"></i> <span class="title">我需要帮助</span>
						</a>
					</li>
				</ul>
				<!-- END SIDEBAR MENU -->
			</div>
		</div>
		<!-- END SIDEBAR -->
		<!-- BEGIN CONTENT -->
		<div class="page-content-wrapper">
			<div class="page-content">
				<!-- BEGIN STYLE CUSTOMIZER -->
				<div class="theme-panel hidden-xs hidden-sm">
					<div class="toggler-close"></div>
					<div class="theme-options">
						<div class="theme-option theme-colors clearfix">
							<span> THEME COLOR </span>
							<ul>
								<li class="color-default tooltips" data-style="default"
									data-container="body" data-original-title="Default"></li>
								<li class="color-darkblue tooltips" data-style="darkblue"
									data-container="body" data-original-title="Dark Blue"></li>
								<li class="color-blue tooltips" data-style="blue"
									data-container="body" data-original-title="Blue"></li>
								<li class="color-grey tooltips" data-style="grey"
									data-container="body" data-original-title="Grey"></li>
								<li class="color-light tooltips" data-style="light"
									data-container="body" data-original-title="Light"></li>
								<!-- 
							<li class="color-light2 tooltips" data-style="light2" data-container="body" data-html="true" data-original-title="Light 2">
							</li>
							 -->
								<li class="color-light2 current tooltips" data-style="light.rap"
									data-container="body" data-html="true"
									data-original-title="Light2-RAP"></li>
							</ul>
						</div>
						<div class="theme-option">
							<span> Layout </span> <select
								class="layout-option form-control input-small">
								<option value="fluid" selected="selected">Fluid</option>
								<option value="boxed">Boxed</option>
							</select>
						</div>
						<div class="theme-option">
							<span> Header </span> <select
								class="page-header-option form-control input-small">
								<option value="fixed" selected="selected">Fixed</option>
								<option value="default">Default</option>
							</select>
						</div>
						<div class="theme-option">
							<span> Sidebar Mode</span> <select
								class="sidebar-option form-control input-small">
								<option value="fixed">Fixed</option>
								<option value="default" selected="selected">Default</option>
							</select>
						</div>
						<div class="theme-option">
							<span> Sidebar Menu </span> <select
								class="sidebar-menu-option form-control input-small">
								<option value="accordion" selected="selected">Accordion</option>
								<option value="hover">Hover</option>
							</select>
						</div>
						<div class="theme-option">
							<span> Sidebar Style </span> <select
								class="sidebar-style-option form-control input-small">
								<option value="default" selected="selected">Default</option>
								<option value="light">Light</option>
							</select>
						</div>
						<div class="theme-option">
							<span> Sidebar Position </span> <select
								class="sidebar-pos-option form-control input-small">
								<option value="left" selected="selected">Left</option>
								<option value="right">Right</option>
							</select>
						</div>
						<div class="theme-option">
							<span> Footer </span> <select
								class="page-footer-option form-control input-small">
								<option value="fixed">Fixed</option>
								<option value="default" selected="selected">Default</option>
							</select>
						</div>
					</div>
				</div>
				<!-- END STYLE CUSTOMIZER -->
				<!-- BEGIN PAGE CONTENT-->
				<div id="rap-div-funcarea">
					<iframe id="rap-iframe-func-dashboard" class="rap-iframe-func" src="${ctx}/dashboard?sysId=${sysId}" frameborder="0" width="100%"></iframe>
				</div>
				<!-- END PAGE CONTENT-->
			</div>
		</div>
		<!-- END CONTENT -->
	</div>
	<!-- END CONTAINER -->
	<!-- BEGIN FOOTER -->

	<!-- END FOOTER -->
	<script src="${ctx}/assets/metronic_v3.2.0/admin/layout/scripts/layout.js" type="text/javascript"></script>
	<script src="${ctx}/assets/metronic_v3.2.0/admin/layout/scripts/demo.js" type="text/javascript"></script>
	<script>
		//在首页加载枚举数据，如果单独访问页面方式需要调用该方法
		RapDataUtils.loadEnumData();

		//JS中缓存用户信息
		var loginUser = {
			"uuid" : "${user.uuid}",
			"loginName" : "${user.loginName}",
			"userName" : "${user.userName}",
			"groupOneCodes" : "${user.groupOneCodes}",
			"groupOneNames" : "${user.groupOneNames}",
			"groupTwoCodes" : "${user.groupTwoCodes}",
			"groupTwoNames" : "${user.groupTwoNames}"
		};
		sessionStorage.loginUser = JSON.stringify(loginUser);
		
		//Js中缓存系统Id
		sessionStorage.setItem("sysId","${sysId}");

		var _MAX_OPENFUNC = 20; //最大打开功能点数量
		var _funcCount = 0; //当前数量
		var _funcContainer; //功能iframe容器
		var _iframeHeight;
		
		//打开功能，先查找是否已经打开，如果已打开则显示，否则新建iframe显示
		//@funcid:功能注册uuid
		//@funcname:功能名称
		//@url:功能url
		function openFunc(funcid, funcname, src) {
			var iframeid = getIframeId(funcid);
			var o = _funcContainer.find("#" + iframeid);
			if(o.length > 0){
				showFuncIframe(funcid);
				return;
			}
			
			if (_funcCount < _MAX_OPENFUNC) {
				addFuncIframe(funcid, src);
				addFuncList(funcid, funcname);
				showFuncIframe(funcid);
			} else {
				alert("只能同时打开" + _MAX_OPENFUNC + "个功能，请先关闭其他不使用的功能");
			}
		}
		
		function closeFunc(fid){
			showDashboard();
			removeFuncIframe(fid);
			removeFuncList(fid);
			updateFuncCount();
		}
		
		//************ 功能IFrame控制 *************//
		function getIframeId(fid) {
			return "rap-iframe-func-" + fid;
		}
		var iframeTpl = "<iframe id='{iframeid}' class='rap-iframe-func' src='{src}' frameborder='0' width='100%'></iframe>"
		function addFuncIframe(fid, src) {
			var iframeid = getIframeId(fid);
			var iframe = $(iframeTpl.replace(/\{iframeid\}/g, iframeid).replace(/\{src\}/g, src));
			iframe.attr('style', 'min-height:' + _iframeHeight + 'px');
			_funcContainer.append(iframe);
			_funcCount++;
		}
		function removeFuncIframe(fid) {
			var iframeid = getIframeId(fid);
			var iframe = _funcContainer.find("#" + iframeid);
			if (iframe) {
				iframe.remove();
				_funcCount--;
			}
		}
		function showFuncIframe(fid) {
			var iframeid = getIframeId(fid);
			_funcContainer.find("iframe").each(function() {
				//alert($(this).attr('id'));
				if ($(this).attr('id') != iframeid) {
					$(this).addClass("hide");
				} else {
					$(this).removeClass("hide");
				}
			});
		}
		function showDashboard(){
			$("#rap-iframe-func-dashboard").attr("src","${ctx}/dashboard?sysId=${sysId}");
			showFuncIframe("dashboard");
		}
		function showHelp(){
			$("#rap-iframe-func-dashboard").attr("src","http://www.baidu.com");
			showFuncIframe("dashboard");
		}
		//************ 打开功能列表菜单控制 *************//
		function updateFuncCount(){
			$(".rap-funcs-count").html(_funcCount);
		}
		function getLiId(fid) {
			return "rap-li-func-" + fid;
		}
		var listTpl = "<li id='{liid}' class='external rap-li-func'><a href=\"javascript:showFuncIframe('{fid}');\">{fname}<i class='icon-close' onclick=\"closeFunc('{fid}'); return false;\"></i></a></li>";
		function addFuncList(fid, name) {
			var liid = getLiId(fid);
			var li = $(listTpl.replace(/\{liid\}/g, liid).replace(/\{fid\}/g, fid).replace(/\{fname\}/g, name));
			$("#rap-ul-funcs-list").append(li);
			updateFuncCount();
		}
		function removeFuncList(fid) {
			var liid = getLiId(fid);
			$("#" + liid).remove();
			updateFuncCount();
		}
		function closeAllFunc() {
			showDashboard();
			_funcContainer.find(".rap-iframe-func").not("#rap-iframe-func-dashboard").each(
					function() {
						$(this).remove();
					});
			$(".rap-li-func").each(function() {
				$(this).remove();
			});
			_funcCount = 0;
			updateFuncCount();
		}
		function onBack(){
			var url ='${ctx}/system';
			var sysSize = '${sysSize}';
			if(sysSize!=null&&sysSize==1){
				url = '${ctx}/logout';
			}
			window.location=url;
		}
		jQuery(document).ready(function() {
			_funcContainer = $("#rap-div-funcarea");
			
			Metronic.init(); // init metronic core components
			Layout.init(); // init current layout
			Demo.init(); // init demo features
			
			_iframeHeight = $("#rap-iframe-func-dashboard").outerHeight();
			
			//主题设置面板开关
			$(".rap-config-toggler").click(function() {
				$('.toggler-close').show();
				$('.theme-panel > .theme-options').show();
			});

			$("#rap-change-pwd").colorbox({
				iframe : true,
				href : "${ctx}/modules/sys/user/pwd",
				innerWidth : '300px',
				innerHeight : '310px'
			});

			$('.rap-func').click(function() {
				$('.active').removeClass('active');
				$(this).closest('li').addClass('active');
			});
		});
	</script>
</body>
</html>
